﻿
namespace zykControl
{
    /// <summary>拼音选择下拉框</summary>
    public partial class PYCombo
    {
        /// <summary>拼音选择下拉框</summary>
        public PYCombo()
        {
            // 此调用是 Windows 窗体设计器所必需的。
            InitializeComponent();

            // 在 InitializeComponent() 调用之后添加任何初始化。
            ErrorProvider1.ContainerControl = FindForm();
        }

        /// <summary>
        /// 设置一组拼音码
        /// </summary>
        /// <param name="theText"></param>
        /// <remarks></remarks>
        public void SetPYs(string[] theText)
        {
            Text = "";
            DataSource = theText;
            if (theText.Length > 1)
                ErrorProvider1.SetError(this, "发现多音字!");
            else
                ErrorProvider1.SetError(this, "");
        }

        /// <summary>
        /// 清除所有内容
        /// </summary>
        /// <remarks></remarks>
        public void ClearPYs()
        {
            DataSource = null;
            Text = "";
            ErrorProvider1.SetError(this, "");
        }

        /// <summary>
        /// 设置一个拼音码
        /// </summary>
        /// <param name="theText"></param>
        /// <remarks></remarks>
        public void SetPYs(string theText)
        {
            SetPYs(new string[] { theText });
            ErrorProvider1.SetError(this, "");
        }
    }
}